<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>放款合同意见</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<form id="formSet1">
			<div class="fieldset1 tabel_col clearFix">
				<%-- <div class="fieldBox col_100">
		            <div class="label">付款流程</div>
		            <div class="field">
		                <span>${procNm}</span>
		            </div>
		        </div> --%>
				<div class="fieldBox col_50">
		            <div class="label">项目类型</div>
		            <div class="field">
		                <span>${prjBscInfoVO.prjTypCdNm}</span>
		            </div>
		        </div>
				<%-- <div class="fieldBox col_50">
		            <div class="label">业务模式</div>
		            <div class="field">
		                <span>${prjBscInfoVO.bizTypCdNm}</span>
		            </div>
		        </div>  --%>
				<div class="fieldBox col_50">
		            <div class="label">放款流程类型</div>
		            <div class="field">
		                <span>${capPayInfoVO.payTypCdNm}</span>
		            </div>
		        </div>
		        <div class="fieldBox col_50">
					<div class="label">是否挂靠</div>
		            <div class="field">
		                <select name="isAnchored" id="isAnchored" data-value=" " validate="{required:true,select:true}">
		                	<option value=" " checked>请选择</option>
							<c:forEach items="${yesOrNOList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
		                </select>
		                <span class="requiredSymbol">*</span>
		            </div>
				</div>
		        <div class="fieldBox col_50">
					<div class="label">是否上传保单</div>
		            <div class="field">
		                <select name="isUploadIns" id="isUploadIns" onchange="isUploadInsChange();" validate="{required:true,select:true}">
		                	<option value=" ">请选择</option>
							<c:forEach items="${yesOrNOList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
		                </select>
		                <span class="requiredSymbol">*</span>
		            </div>
				</div>
				<div class="fieldBox col_50" id="isComplianceBeneficiaryDIV" style="display: none">
					<div class="label">第一受益人是否合规</div>
		            <div class="field">
		                <select name="isComplianceBeneficiary" id="isComplianceBeneficiary">
		                	<option value=" ">请选择</option>
							<c:forEach items="${yesOrNOList }" var="kv">
								<option value="${kv.key }">${kv.value }</option>
							</c:forEach>
		                </select>
		                <span class="requiredSymbol">*</span>
		            </div>
				</div>
				<div class="fieldBox col_50" id="isCompleteInsuranceDIV" style="display: none">
					<div class="label">险种是否齐全</div>
			            <div class="field">
			                <select name="isCompleteInsurance" id="isCompleteInsurance">
			                	<option value=" ">请选择</option>
								<c:forEach items="${yesOrNOList }" var="kv">
									<option value="${kv.key }">${kv.value }</option>
								</c:forEach>
			                </select>
			                <span class="requiredSymbol">*</span>
			            </div>
				</div>
				<div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="remark" id="remark" rows="4" class="l-textarea" style="width:90%" value="${audPayPassOpinionVO.remark}" ></textarea>
                    </div>
                </div>
			</div>
			<div class="btnsBox">
				<input name="payPassOpinionId" id="payPassOpinionId" type="hidden" value="${audPayPassOpinionVO.id}">
			</div>
		</form>
	</div>

<script type="text/javascript">
var _capPayId = '${capPayId}';//付款信息ID
var _proIntId = '${proIntId}';//流程实例ID

$(function(){
	$('#formSet1').ligerForm({
        validate : true
	});
	initData();
});
frameElement.dialog.onOk = function () {
	saveAudPassOpn();
}
frameElement.dialog.onCancel = function () {
    frameElement.dialog.close();
}
frameElement.dialog.preview = function () {
    //预览
	getPreviewString();
}
//预览
function getPreviewString(){
	var payPassOpinionId = $("#payPassOpinionId").val();
	if(StringUtils.isEmpty(payPassOpinionId)){
		$.ligerDialog.SQalert({content: "请先保存信息!" , SQ_type: "warning" });
		return;
	}
	top.$.ligerDialog.SQopen({
        width: 600,
        height:250,
        top:200,
        title : '预览',
        url:'<%=path%>/audit/audPayPassOpinion/toPreviewPage.do?flag=htForXny&id='+payPassOpinionId,
        buttons: [
                {
	            text: "关闭", type: 'cancel', cls: 'l-dialog-btn-no',
	            onclick: function (item, Dialog) {
	                if (Dialog.onCancel) Dialog.onCancel();
	            }
	        }
	    ]
    });
}
function initData(){
	var payPassOpinionId = $("#payPassOpinionId").val();
	if(StringUtils.isEmpty(payPassOpinionId)) return;
	var form = liger.get("formSet1");
	$("#remark").val("${audPayPassOpinionVO.remark}");
	form.setData({
		isComplianceBeneficiary:'${audPayPassOpinionVO.isComplianceBeneficiary}',
		isCompleteInsurance:'${audPayPassOpinionVO.isCompleteInsurance}',
		isAnchored:'${audPayPassOpinionVO.isAnchored}',
		isUploadIns:'${audPayPassOpinionVO.isUploadIns}',
	});
}

function saveAudPassOpn(){
	var form = liger.get("formSet1");
    if (!form.valid()) {
    	$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO , SQ_type: "warning" });
        return false;
    }
    var data = form.getData();
    data["capPayId"] = _capPayId;//付款信息ID
    data["proIntId"] = _proIntId;//流程实例ID
    data["opnTypCd"] = AuditConstant.AUD_PAY_OPN_TYP_CD_CONTRACT; //放款通过意见类型
    
    var id = $("#payPassOpinionId").val();
    var url = '<%=path%>/audit/audPayPassOpinion/add.do';
    if(id != ""){
    	url = '<%=path%>/audit/audPayPassOpinion/modify.do';
    	data["id"]= id;
    }
   var wait_dialog;
    $.ajax({
		type: 'post',
		dataType:'json',
		data:data,
		url: url,
		beforeSend: function(){
	          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
	     },
		success:function(msg){
			 wait_dialog.close();
			 if(msg.success == 1){
				 if(msg.data){
					 $("#payPassOpinionId").val(msg.data);
				 }
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
				 //frameElement.dialog.close();
			 }else{
				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
			 }
		}
	});
}

function isUploadInsChange(){
	var _isUploadIns = $("#isUploadIns").val();
	if(StringUtils.isEmpty(_isUploadIns)) return;
	var formSet1=liger.get("formSet1");
	if(_isUploadIns==1){
		$("#isComplianceBeneficiaryDIV").show();
		$("#isCompleteInsuranceDIV").show();
		formSet1.setFieldValidate("isComplianceBeneficiary", {
	        required: true,
	        select: true
	    });
		formSet1.setFieldValidate("isCompleteInsurance", {
	        required: true,
	        select: true
	    });
	}else if(_isUploadIns==0){
		$("#isComplianceBeneficiaryDIV").hide();
		$("#isCompleteInsuranceDIV").hide();
		formSet1.setFieldValidate("isComplianceBeneficiary", {
	        required: false,
	        select: false
	    });
		formSet1.setFieldValidate("isCompleteInsurance", {
	        required: false,
	        select: false
	    });
	}
}

</script>
</body>
</html>
